package com.zhixiang.xaec.action.safebase.securitySystem;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.google.gson.Gson;
import com.zhixiang.core.command.QueryFilter;
import com.zhixiang.core.entity.TreeObj;
import com.zhixiang.core.util.YearGridCrud;
import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.safebase.securitySystem.InstituArchRev;
import com.zhixiang.xaec.service.safebase.securitySystem.InstituArchRevService;


@Controller
@Scope("prototype")
public class InstituArchRevAction extends BaseAction{

    private static final long serialVersionUID = -2011305013656502596L;
    
    private InstituArchRev instituArchRev; 
    @Autowired
    private InstituArchRevService instituArchRevService;
    
  
   
    public InstituArchRev getInstituArchRev() {
        return instituArchRev;
    }

    public void setInstituArchRev(InstituArchRev instituArchRev) {
        this.instituArchRev = instituArchRev;
    }
    
    public String list() {
        QueryFilter localQueryFilter = new QueryFilter(getRequest());
        List<InstituArchRev> localList = this.instituArchRevService.getAll(localQueryFilter);
        setSuccess(true);
        setTotalCounts(localQueryFilter.getPagingBean().getTotalItems());
        // 返回结果集
        setResult(localList);
        return SUCCESS;
    }

    public String listArchRev(){
        String archid = getRequest().getParameter("archid");
        List<InstituArchRev> localList = this.instituArchRevService.findByIntitutionId(archid);
        setSuccess(true);
        /*setTotalCounts(localQueryFilter.getPagingBean().getTotalItems());
        // 返回结果集
*/        setResult(localList);
        return SUCCESS;
    }
    
    public String get() {
        String id = getRequest().getParameter("id");
        if (!"".equals(id) && id != null) {
            setResult(instituArchRevService.getInstitutionalId(id));
        }
        return SUCCESS;
    }

    public String getList() {
        String id = getRequest().getParameter("id");
        if (!"".equals(id) && id != null) {
            setResult(instituArchRevService.get(Long.valueOf(id)));
        }
        return SUCCESS;
    }
    
    public String delete() {
        String[] ids = getRequest().getParameterValues("ids");
        instituArchRevService.delete(ids);
        return SUCCESS;
    }

    public String save() {
        instituArchRevService.saveIntituArchRev(instituArchRev);
        return SUCCESS;
    }
    
    //实现年份数的方法
    public String treeLoad(){
        List<TreeObj> treeList=YearGridCrud.treeLoad();
        if(treeList!=null){
            outJsonString(new Gson().toJson(treeList));
        }       
        return SUCCESS;
    }
 
}
